/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package me.everdras.blackPlague.commands;

import java.util.logging.Logger;
import me.everdras.blackPlague.PlagueSpreadListener;
import me.everdras.blackPlague.PlagueThread;
import org.bukkit.entity.Player;

/**
 *
 * @author Josh
 */
public abstract class CommandHandler {
    
    public static void startPlague(Player sender, PlagueSpreadListener listener) {
        if(listener.getPlagueThread() != null && listener.getPlagueThread().isAlive()) {
            sender.sendMessage("Plague is already in effect.");
            return;
        }
            
        PlagueThread pt = new PlagueThread();
        pt.start();
        
        listener.setPlagueThread(pt);
        
        sender.sendMessage("You contort dark energy to brew up a plague.");
        Logger.getLogger("Minecraft").info(sender.getName() + " has started a plague.");
        
    }
    
    public static void endPlague(Player sender, PlagueThread plague) {
        
        if(plague == null || !plague.isAlive()) {
            sender.sendMessage("Plague is already dead.");
            return;
        }
        
        plague.terminate();
        sender.sendMessage("Your incantations cease- the stench of the plague filters from the air.");
        Logger.getLogger("Minecraft").info(sender.getName() + " has ended the plague.");
        
        
    }
    
    
    
    public static void infect(PlagueThread plague, Player sender, Player other) {
        if(plague != null && plague.isAlive()) {
            plague.addInfected(other);
        
            other.sendMessage(org.bukkit.ChatColor.DARK_BLUE + "You were infected by a dark power!");
            sender.sendMessage(org.bukkit.ChatColor.AQUA + "You employ dark magicks to infect " + other.getName() + ".");
            Logger.getLogger("Minecraft").info(sender.getName() + " has infected " + other.getName() + " by command.");
        }
        else
            sender.sendMessage("Plague is extinct, cannot infect anyone.");
        
        
    }
    
    public static void cure(PlagueThread plague, Player sender, Player other) {
        if(plague != null && plague.isAlive()) {
            plague.cure(other);
        }
        else
            sender.sendMessage("Plague is extinct, cannot cure anyone.");
        
    }
    
    public static void setTickDelay(double seconds) {
        
    }
    
    public static void setTickAmount(double hearts) {
        
    }
    
    
    
}
